/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package riotlogic;

import java.awt.image.BufferedImage;

/**
 *
 * @author aperezc2
 */
public class Character extends TangibleObject{
    //TODO: Complete shiftFacing method.

    float maxHP;    
    float currentHP;
    int speed;
    Weapon wpn;
    Point pnt = new Point();
    char facing;
    protected BufferedImage image;
    protected int yAcceleration;
    
    public Character(String name, int hp, int speed, Weapon wpn, int x, int y,char facing){
        super(name);
        this.maxHP = hp;
        this.currentHP = hp;
        this.wpn = wpn;
        this.speed = speed/(int)wpn.weight;
        this.pnt.setX(x);
        this.pnt.setY(y);
        this.facing = facing;//L, R
        this.yAcceleration = 0;
    }

    public float attack(Character target){
        float dealDmg = this.wpn.atkPow/target.maxHP;
        return dealDmg;
    }

    public Weapon getWeapon(){return wpn;}
    public int getMaxHP(){return (int)maxHP;}
    public int getCurrentHP(){return (int)currentHP;}
    public int getSpeed(){return speed;}
    public char getFacing(){return facing;}

    public void shiftFacing(){
    	if(facing == 'L'){
    		facing = 'R'; 
    	}
    	else{
    		facing = 'L';
    	}
    }
    public int getX(){
    	return pnt.getX();
    }
    public int getY(){
    	return pnt.getY();
    }
    
    public void simulatedGravityEffect(){
    	if(pnt.getY() < 700 - this.image.getHeight() - 20){
            this.pnt.setY(pnt.getY() + yAcceleration); //Use acceleration for 3D
            if(yAcceleration < 6 ){
                yAcceleration += 1;
            }
    	}
    }
    public BufferedImage getSprite(){
    	return this.image;
    }
}